import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

let state={
	hasLogin: false,
	userInfo: {},
}
const userInfo = uni.getStorageSync('userInfo')
if(userInfo){
	state.userInfo = userInfo
}
const store = new Vuex.Store({
	state: state,
	mutations: {
		login(state, provider) {
			state.hasLogin = true;
			state.userInfo = provider;
			uni.setStorage({//缓存用户登陆状态
			    key: 'userInfo',  
			    data: provider  
			}) 
		},
		logout(state) {
			state.hasLogin = false;
			state.userInfo = {};
			uni.removeStorage({  
                key: 'userInfo'  
            })
		}
	},
	actions: {
	
	},
	getters:{

	}
})

export default store
